/*************************************************************************
	> File Name: P1889.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-02-17 16:01:03
 ************************************************************************/
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

#define MAX_N 10000
int x[MAX_N + 5], y[MAX_N + 5];
int n;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> x[i] >> y[i];
    }
    sort(y + 1, y + 1 + n);
    sort(x + 1, x + 1 + n);
    for (int i = 1; i <= n; i++) {
        x[i] -= i;
    }
    sort(x + 1, x + 1 + n);
    int tx = x[(n + 1) / 2], ty = y[(n + 1) / 2];
    long long sum = 0;
    for (int i = 1; i <= n; i++) {
        sum += abs(x[i] - tx);
        sum += abs(y[i] - ty);
    }
    cout << sum << endl;
    return 0;
}
